using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using Voodoo.Pattern;

public class EndScreenView : MonoBehaviour
{
	public CanvasGroup _group;

	private Action RVAction;

	private Action NoThanksAction;

	public List<GameObject> _NoOilObjects = new List<GameObject>();

	public List<GameObject> _LevelCompleteObjects = new List<GameObject>();

	public List<GameObject> _LevelFailedObjects = new List<GameObject>();

	public TextMeshProUGUI _earnedText;

	public TextMeshProUGUI _multiplyText;

	private EndScreenMode _currentMode;

	public void ShowScreen(EndScreenMode mode, Action _rvAction, Action _noThanks)
	{
		_currentMode = mode;
		_NoOilObjects.SetActive(isActive: false);
		_LevelFailedObjects.SetActive(isActive: false);
		_LevelCompleteObjects.SetActive(isActive: false);
		_earnedText.text = Mathf.CeilToInt(UnityEngine.Object.FindObjectOfType<Sell>().deltaMoney) + "$";
		_multiplyText.text = "+" + Mathf.CeilToInt(UnityEngine.Object.FindObjectOfType<Sell>().deltaMoney) * 2 + "$";
		switch (mode)
		{
		case EndScreenMode.LevelCompelete:
			_LevelCompleteObjects.SetActive(isActive: true);
			break;
		case EndScreenMode.LevelFailed:
			_LevelFailedObjects.SetActive(isActive: true);
			break;
		case EndScreenMode.NoOIl:
			_NoOilObjects.SetActive(isActive: true);
			break;
		}
		RVAction = _rvAction;
		NoThanksAction = _noThanks;
		_group.Show();
	}

	public void OnRVClick()
	{
		RVAction?.Invoke();
		Hide();
	}

	public void OnNoThanksClick()
	{
		NoThanksAction?.Invoke();
		Hide();
	}

	private void Hide()
	{
		_group.Hide();
	}

	private void Start()
	{
		if (SingletonMB<MessageCenter>.Instance != null)
		{
			MessageCenter instance = SingletonMB<MessageCenter>.Instance;
			instance.ShowEndScreen = (Action<EndScreenMode, Action, Action>)Delegate.Combine(instance.ShowEndScreen, new Action<EndScreenMode, Action, Action>(ShowScreen));
		}
		_group.Hide();
	}

	private void OnDestroy()
	{
		if (SingletonMB<MessageCenter>.Instance != null)
		{
			MessageCenter instance = SingletonMB<MessageCenter>.Instance;
			instance.ShowEndScreen = (Action<EndScreenMode, Action, Action>)Delegate.Remove(instance.ShowEndScreen, new Action<EndScreenMode, Action, Action>(ShowScreen));
		}
	}

	private void Update()
	{
	}
}
